import pandas as pd
import numpy as np

s = pd.Series([1, 3, 6, np.nan, 44, 1])
print(s)

# 生成6个日期
dates = pd.date_range('20200601', periods=6)
print(dates)

# 给数据加上名字
df = pd.DataFrame(np.random.randn(6, 4), index=dates, columns=['a', 'b', 'c', 'd'])
print(df)
print(df.dtypes)
# 输出所有索引的序号
print(df.index)
# 输出所有标签的序号
print(df.columns)
# 去掉名字输出所有数据,变成numpy.ndarray
print(df.values)
print(type(df.values))

# 描述数据
print(df.describe())
#               a         b         c         d
# count  6.000000  6.000000  6.000000  6.000000
# mean  -0.348801  0.067065 -0.457581 -0.129502
# std    0.902907  1.104237  0.487844  0.585456
# min   -1.597613 -0.983945 -0.943773 -0.871202
# 25%   -0.596238 -0.660975 -0.843893 -0.620207
# 50%   -0.570939 -0.111451 -0.585289 -0.020675
# 75%   -0.031700  0.255215 -0.082234  0.319979
# max    1.103309  2.075953  0.213508  0.522059

# 数据转置
print(df.T)

# 排序
print(df.sort_index(axis=1,ascending=False)) # 按列逆排序
print(df.sort_values(by='a',ascending=False))